﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace tww
{
    public partial class oauthreturn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["oauth_token"] != null && Request.QueryString["oauth_verifier"] != null)
            {
                string oauth_token = Request.QueryString["oauth_token"];
                string oauth_verifier = Request.QueryString["oauth_verifier"];

                OAuthHelper oauthhelper = new OAuthHelper();
                oauthhelper.GetUserTwAccessToken(oauth_token, oauth_verifier);

                if (string.IsNullOrEmpty(oauthhelper.oauth_error))
                {
                    Session["twtoken"] = oauthhelper.oauth_access_token;
                    Session["twsecret"] = oauthhelper.oauth_access_token_secret;
                    Session["TwitterObjectid"] = oauthhelper.user_id;
                    Session["twname"] = oauthhelper.screen_name;

                    Response.Redirect("/default.aspx");
                    
                }
                else
                    Response.Write(oauthhelper.oauth_error);
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }
    }
}